package demo4;

import java.util.Arrays;

/**
 * @Author: XXHH
 * @CreateTime: 2025-01-12
 */
public class Test {
    public static void main(String[] args) {
        Student[] students = new Student[3];
        students[0] = new Student("张三",20);
        students[1] = new Student("王五",23);;
        students[2] = new Student("李四",18);
        AgeCompator ageCompator = new AgeCompator();
        System.out.println("排序前的数组:"+Arrays.toString(students));
        Arrays.sort(students,ageCompator);
        System.out.println("排序后的数组"+Arrays.toString(students));
    }
    public static void main3(String[] args) {
        Student[] students = new Student[3];
        students[0] = new Student("张三",20);
        students[1] = new Student("王五",23);;
        students[2] = new Student("李四",18);
        NameCompator nameCompator = new NameCompator();

        System.out.println("排序前的数组:"+Arrays.toString(students));
        Arrays.sort(students,nameCompator);
        System.out.println("排序后的数组"+Arrays.toString(students));

    }
    public static void main2(String[] args) {
        Student student = new Student("张三",20);
        Student student1 = new Student("李四",23);
//        if (student1.compareTo(student)>0){
//            System.out.println("student1比Student大");
//        }else if (student1.compareTo(student)==0){
//            System.out.println("student1比Student一样大");
//        }else {
//            System.out.println("student1比Student小");
//        }
//        String s =new String();
       // System.out.println(student.compare(student1,student));
    }
}
